package com.wc.alorithm_blue_bridge._数学知识.约数.既约分数;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

/**
 * @Author congege
 * @Description
 * @Date Created in 2023/11/24-21:09
 */
public class Main2 {
    public static void main(String[] args) {
        Input sc = new Input();
        int n = sc.nextInt();
        int[] nums = new int[2000 + 1];
        nums[1] = 1;
        int ans = 0;
        for (int i = 1; i <= 2000; i++) {
            for (int j = 1; j <= i - 1; j++) {
                if (gcd(i,j)==1){
                    ans++;
                    if (j + 1 == i){
                        nums[i] = ans * 2 + 1;
                    }
                }
            }
        }
        while (n-- > 0) {
            int num = sc.nextInt();
            System.out.println(nums[num]);
        }
    }

    public static int gcd(int num1, int num2) {
        if (num1 > num2) {
            return gcd(num2, num1);
        }
        while (num2 % num1 != 0) {
            num2 = num2 % num1;
            num1 = num2 + num1;
            num2 = num1 - num2;
            num1 = num1 - num2;
        }
        return num1;
    }

    static class Input {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (int) in.nval;
        }
    }
}
